package com.smile.publisher.service.Impl;

import com.smile.publisher.mapper.OrderWideMapper;
import com.smile.publisher.service.ClickHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ClickHouseServiceImpl implements ClickHouseService {
    @Autowired
    OrderWideMapper orderWideMapper;

    @Override
    public BigDecimal selectOrderAmountTotal(String date) {
        return  orderWideMapper.selectOrderAmountTotal(date);
    }

    @Override
    public List<Map<String, BigDecimal>> selectOrderAmountHour(String date) {
        Map<String, BigDecimal> rsMap = new HashMap<>();
        List<Map> mapList = orderWideMapper.selectOrderAmountHour(date);
        for(Map map:mapList){
            //key值应该与OrderWiderMapper.xml中的key值保持一致
            rsMap.put(String.format("%02d",map.get("hr")),(BigDecimal) map.get("am")); //转换类型
        }
        return null;
    }
}
